'use strict';

module.exports = {
  async up (queryInterface, Sequelize) {
    // 检查列是否已存在，避免重复添加
    const tableInfo = await queryInterface.describeTable('users');
    if (!tableInfo.phone_number) {
      await queryInterface.addColumn('users', 'phone_number', {
        type: Sequelize.STRING,
        allowNull: true
      });
    }
  },

  async down (queryInterface, Sequelize) {
    // 检查列是否存在，避免删除不存在的列
    const tableInfo = await queryInterface.describeTable('users');
    if (tableInfo.phone_number) {
      await queryInterface.removeColumn('users', 'phone_number');
    }
  }
};
